package com.easthome.controller;

import com.easthome.common.RespResult;
import com.easthome.entity.Address;
import com.easthome.entity.UserInfo;
import com.easthome.service.AddrService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.SessionAttribute;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/addr")
public class AddrController {

    @Autowired
    private AddrService addrService;

@RequestMapping("/getAddrList")
    public RespResult getAddrList(){
    List<Address> list = addrService.getAddrList();

    return RespResult.success(list);
}
@RequestMapping("/addAddAndCho")
    public RespResult addAddAndCho( @RequestBody Address address,@SessionAttribute UserInfo user){
     int r= addrService.addAddAndCho(user.getUserId(),address);
    System.out.println("返回的主键"+r);
    return RespResult.success(r);
}

}
